﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CheckFountainTutorialCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var userModel:UserModel;
		[Inject]
        public var worldModel:WorldModel;
		[Inject]
        public var tutorialModel:TutorialModel;

        private static const MIN_LEVEL_FOR_FOUNATIN_TUTORIAL:Number = 5;

        override public function execute():void{
            l(("execute: " + this.execute));
            if (((!(this.userModel.isVisitFriendsMode())) && ((this.userModel.level >= MIN_LEVEL_FOR_FOUNATIN_TUTORIAL)))){
                this.checkFountainTutorial();
            };
        }
        private function checkFountainTutorial():void{
            var _local2:ITreatable;
            var _local3:int;
            var _local4:TreatmentVO;
            var _local5:int;
            l(("checkFountainTutorial: " + this.checkFountainTutorial));
            var _local1:Boolean = this.worldModel.hasAreaType(GameConstants.TYPE_FOUNTAIN);
            if (((!(_local1)) && (this.event.info.state))){
                if (!this.tutorialModel.isInTutorialMode){
                    this.tutorialModel.state = int(this.event.info.state);
                };
            } else {
                if (this.event.info.patient){
                    _local2 = (this.event.info.patient as ITreatable);
                    if ((((((_local2.diseaseName == WorldConstants.DISEASE_OLD)) && (!((_local2.state == WorldConstants.CURED))))) && (!((_local2.state == WorldConstants.BABY))))){
                        _local3 = 0;
                        for each (_local4 in _local2.treatments) {
                            for each (_local5 in _local4.symbols) {
                                _local3 = (_local3 + _local5);
                            };
                        };
                        if (_local3 == 1){
                            dispatch(new InfoEvent(EventConstants.SHOW_TUTORIAL, _local2.id, {state:TutorialModel.FOUNTAIN_START_TUTORIAL_ELDER, patient:_local2}));
                        };
                    };
                };
            };
        }

    }
}//package net.wooga.pets.controllers 
